# -*- coding: utf-8 -*- 
#
# Description:
#
#  Definiton
#
#
#
# Changes:
#
# 2012-01-10
# Initial Commit
#
#
# Copyright 2010-2012, WyDev Team.
# Author: Polo35 (polo35580@hotmail.fr)
#
# Licenced under Academic Free License version 3.0
# Review WyGui README & LICENSE files for further details.

nname: 0
n 0(None)[GenericContainer.__init__(self, **kw)
self._callback = callback
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75a2e8c>}
nname: 0
n 0(None)[return [ActionItem(name=_('Ethernet'), type_='setupparameters', action=self._callback, args=('802.3',)), ActionItem(name=_('Wireless'), type_='setupparameters', action=self._callback, args=('802.11',))]
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75a448c>}
nname: 6
n 6(None)[def __init__(self, callback, **kw):
	GenericContainer.__init__(self, **kw)
	self._callback = callback

def browse(self):
	return [ActionItem(name=_('Ethernet'), type_='setupparameters', action=self._callback, args=('802.3',)), ActionItem(name=_('Wireless'), type_='setupparameters', action=self._callback, args=('802.11',))]

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb75a294c>}
nname: 0
n 0(None)[GenericContainer.__init__(self, **kw)
self._callback = callback
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75a2fcc>}
nname: 0
n 0(None)[return [ActionItem(name=_('Automatic'), type_='setupparameters', action=self._callback, args=('upnp',)), ActionItem(name=_('Manual'), type_='setupparameters', action=self._callback, args=('static',))]
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75a44ac>}
nname: 6
n 6(None)[def __init__(self, callback, **kw):
	GenericContainer.__init__(self, **kw)
	self._callback = callback

def browse(self):
	return [ActionItem(name=_('Automatic'), type_='setupparameters', action=self._callback, args=('upnp',)), ActionItem(name=_('Manual'), type_='setupparameters', action=self._callback, args=('static',))]

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb75a28ac>}
nname: 0
n 0(None)[GenericContainer.__init__(self, **kw)
self._callback = callback
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75a2dec>}
nname: 104
n 104(None)[return it_list
]:
	i: 0(AL), 103()
	o: 

nname: 103
n 103(None)[]:
	i: 25(AF), 38()
	o: 104()

nname: 38
n 38(None)[for key_type, infos in wifi_security_dict.items():
caption = infos['caption']
it_list.append(ActionItem(caption, type_='setupitem', action=self._callback, args=(infos,)))
]:
	i: 25(for)
	o: 103()

nname: 25
n 25(None)[]:
	i: 0(loop)
	o: 38(for), 103(AF)

nname: 0
n 0(None)[from pygui.facilities.codemapping import wifi_security_dict
it_list = []
]:
	i: 
	o: 25(loop), 104(AL)

nname: 104
n 104(None)[return it_list
]:
	i: 38()
	o: 

nname: 38
n 38(None)[for key_type, infos in wifi_security_dict.items():
	caption = infos['caption']
	it_list.append(ActionItem(caption, type_='setupitem', action=self._callback, args=(infos,)))
]:
	i: 0(for)
	o: 104()

nname: 0
n 0(None)[from pygui.facilities.codemapping import wifi_security_dict
it_list = []
]:
	i: 
	o: 38(for)

nname: 104
n 104(None)[return it_list
]:
	i: 0()
	o: 

nname: 0
n 0(None)[from pygui.facilities.codemapping import wifi_security_dict
it_list = []
for key_type, infos in wifi_security_dict.items():
	caption = infos['caption']
	it_list.append(ActionItem(caption, type_='setupitem', action=self._callback, args=(infos,)))
]:
	i: 
	o: 104()

nname: 0
n 0(None)[from pygui.facilities.codemapping import wifi_security_dict
it_list = []
for key_type, infos in wifi_security_dict.items():
	caption = infos['caption']
	it_list.append(ActionItem(caption, type_='setupitem', action=self._callback, args=(infos,)))
return it_list
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75a43cc>}
nname: 6
n 6(None)[def __init__(self, callback, **kw):
	GenericContainer.__init__(self, **kw)
	self._callback = callback

def browse(self):
	from pygui.facilities.codemapping import wifi_security_dict
	it_list = []
	for key_type, infos in wifi_security_dict.items():
		caption = infos['caption']
		it_list.append(ActionItem(caption, type_='setupitem', action=self._callback, args=(infos,)))
	return it_list

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb75a29ec>}
nname: 0
n 0(None)[]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75a2dec>}
nname: 0
n 0(None)[ActionItem.__init__(self, action=self.launch_config, type_='setupparameters', **kw)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75a2eec>}
nname: 0
n 0(None)[from pygui.menu.menu.network_connect import NetworkConnectMenu
NetworkConnectMenu(name='ConnectionMenu', type='network_connect').show()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75a2fcc>}
nname: 6
n 6(None)[def browse(self):
	pass

def __init__(self, *args, **args):
	ActionItem.__init__(self, action=self.launch_config, type_='setupparameters', **kw)

def launch_config(self):
	from pygui.menu.menu.network_connect import NetworkConnectMenu
	NetworkConnectMenu(name='ConnectionMenu', type='network_connect').show()

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb75a28ac>}
nname: 0
n 0(None)[GenericContainer.__init__(self, **kw)
self._callback = callback
self._default_values = default_values
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75a2f0c>}
nname: 0
n 0(None)[self._default_values[key] = value
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75a2fec>}
nname: 0
n 0(None)[return [IpSetupItem(can_modify=True, callback=self._update_values, callback_args=('ipAddress',), active_values=self._default_values), NetmaskSetupItem(can_modify=True, callback=self._update_values, callback_args=('netmask',), active_values=self._default_values), GatewaySetupItem(can_modify=True, callback=self._update_values, callback_args=('gateway',), active_values=self._default_values), DnsSetupItem(dns_num=1, can_modify=True, callback=self._update_values, callback_args=('dns1',), active_values=self._default_values), DnsSetupItem(dns_num=2, can_modify=True, callback=self._update_values, callback_args=('dns2',), active_values=self._default_values), ActionItem(_('Apply'), type_='setupitem', action=self._callback, args=[self._default_values])]
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75a49ec>}
nname: 6
n 6(None)[__doc__ = ' Used for manual network setting '
def __init__(self, callback, default_values, **kw):
	GenericContainer.__init__(self, **kw)
	self._callback = callback
	self._default_values = default_values

def _update_values(self, value, key):
	self._default_values[key] = value

def browse(self):
	return [IpSetupItem(can_modify=True, callback=self._update_values, callback_args=('ipAddress',), active_values=self._default_values), NetmaskSetupItem(can_modify=True, callback=self._update_values, callback_args=('netmask',), active_values=self._default_values), GatewaySetupItem(can_modify=True, callback=self._update_values, callback_args=('gateway',), active_values=self._default_values), DnsSetupItem(dns_num=1, can_modify=True, callback=self._update_values, callback_args=('dns1',), active_values=self._default_values), DnsSetupItem(dns_num=2, can_modify=True, callback=self._update_values, callback_args=('dns2',), active_values=self._default_values), ActionItem(_('Apply'), type_='setupitem', action=self._callback, args=[self._default_values])]

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb75a2b2c>}
nname: 0
n 0(None)[GenericContainer.__init__(self, **kw)
self._can_modify = can_modify
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75a2fec>}
nname: 0
n 0(None)[trans = {'802.3': _('Ethernet'), '802.11': _('Wireless'), None: _('Disconnected')}
active_cfg = wn_cfg.getActiveConfigurationInfos()
dev_infos = wn_dev.getDeviceInfos(active_cfg['interface'])
return [Item(trans[dev_infos['networkType']], type_='setupitem'), IpSetupItem(can_modify=self._can_modify, active_values=dev_infos), NetmaskSetupItem(can_modify=self._can_modify, active_values=dev_infos), GatewaySetupItem(can_modify=self._can_modify, active_values=dev_infos), DnsSetupItem(dns_num=1, can_modify=self._can_modify, active_values=dev_infos), DnsSetupItem(dns_num=2, can_modify=self._can_modify, active_values=dev_infos), Item(_('MAC : %(addr)s') % dict(addr=dev_infos['hwAddress']), type_='setupitem')]
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75a4fec>}
nname: 6
n 6(None)[depth = 2
def __init__(self, can_modify, **kw):
	GenericContainer.__init__(self, **kw)
	self._can_modify = can_modify

def browse(self):
	trans = {'802.3': _('Ethernet'), '802.11': _('Wireless'), None: _('Disconnected')}
	active_cfg = wn_cfg.getActiveConfigurationInfos()
	dev_infos = wn_dev.getDeviceInfos(active_cfg['interface'])
	return [Item(trans[dev_infos['networkType']], type_='setupitem'), IpSetupItem(can_modify=self._can_modify, active_values=dev_infos), NetmaskSetupItem(can_modify=self._can_modify, active_values=dev_infos), GatewaySetupItem(can_modify=self._can_modify, active_values=dev_infos), DnsSetupItem(dns_num=1, can_modify=self._can_modify, active_values=dev_infos), DnsSetupItem(dns_num=2, can_modify=self._can_modify, active_values=dev_infos), Item(_('MAC : %(addr)s') % dict(addr=dev_infos['hwAddress']), type_='setupitem')]

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb75a2b8c>}
nname: 112
n 112(None)[self.addr = active_values[self.attribute]
ActionItem.__init__(self, name=_(self.pattern_name) % dict(<genexpr>(self.pattern_values['name'])), action=self._modify, type_='setupitem', **kw)
]:
	i: 95(t), 108()
	o: 

nname: 108
n 108(None)[]:
	i: 95(f)
	o: 112()

nname: 95
n 95(active_values[self.attribute])[]:
	i: 59(), 94()
	o: 108(f), 112(t)

nname: 94
n 94(None)[]:
	i: 50(t)
	o: 95()

nname: 59
n 59(None)[active_cfg = wn_cfg.getActiveConfigurationInfos()
active_values = wn_dev.getDeviceInfos(active_cfg['interface'])
]:
	i: 50(f)
	o: 95()

nname: 50
n 50(active_values)[_default = _('Disconnected')
]:
	i: 33(), 40()
	o: 59(f), 94(t)

nname: 40
n 40(None)[]:
	i: 0(f)
	o: 50()

nname: 33
n 33(None)[]:
	i: 0(t)
	o: 50()

nname: 0
n 0(can_modify)[self._can_modify = can_modify
self._callback = callback
self._callback_args = callback_args
]:
	i: 
	o: 33(t), 40(f)

nname: 95
n 95(None)[if not active_values[self.attribute]:
	pass
self.addr = active_values[self.attribute]
ActionItem.__init__(self, name=_(self.pattern_name) % dict(<genexpr>(self.pattern_values['name'])), action=self._modify, type_='setupitem', **kw)
]:
	i: 0()
	o: 

nname: 0
n 0(None)[self._can_modify = can_modify
self._callback = callback
self._callback_args = callback_args
if can_modify:
	pass
_default = _('Disconnected')
if not active_values:
	active_cfg = wn_cfg.getActiveConfigurationInfos()
	active_values = wn_dev.getDeviceInfos(active_cfg['interface'])
]:
	i: 
	o: 95()

nname: 0
n 0(None)[self._can_modify = can_modify
self._callback = callback
self._callback_args = callback_args
if can_modify:
	pass
_default = _('Disconnected')
if not active_values:
	active_cfg = wn_cfg.getActiveConfigurationInfos()
	active_values = wn_dev.getDeviceInfos(active_cfg['interface'])
if not active_values[self.attribute]:
	pass
self.addr = active_values[self.attribute]
ActionItem.__init__(self, name=_(self.pattern_name) % dict(<genexpr>(self.pattern_values['name'])), action=self._modify, type_='setupitem', **kw)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75a542c>}
nname: 96
n 96(None)[]:
	i: 21(), 95()
	o: 

nname: 95
n 95(None)[]:
	i: 0(f)
	o: 96()

nname: 21
n 21(None)[self.addr = addr
self.name = _(self.pattern_name) % dict(<genexpr>(self.pattern_values['name']))
self.reset_view()
]:
	i: 0(t)
	o: 96()

nname: 0
n 0(addr not in ('', self.addr))[]:
	i: 
	o: 21(t), 95(f)

nname: 0
n 0(None)[if addr not in ('', self.addr):
	self.addr = addr
	self.name = _(self.pattern_name) % dict(<genexpr>(self.pattern_values['name']))
	self.reset_view()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75a4dec>}
nname: 71
n 71(None)[return None
]:
	i: 47(), 70()
	o: 

nname: 70
n 70(None)[]:
	i: 0(f)
	o: 71()

nname: 47
n 47(None)[self._callback(val, *self._callback_args)
]:
	i: 0(t)
	o: 71()

nname: 0
n 0(self._callback is not None)[val = kbd.text
self.update_addr(val)
kbd.hide()
]:
	i: 
	o: 47(t), 70(f)

nname: 0
n 0(None)[val = kbd.text
self.update_addr(val)
kbd.hide()
if self._callback is not None:
	self._callback(val, *self._callback_args)
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75a580c>}
nname: 18
n 18(None)[def _update():
	val = kbd.text
	self.update_addr(val)
	kbd.hide()
	if self._callback is not None:
		self._callback(val, *self._callback_args)
	return None

kbd = IpWindow(self.addr, title=_(self.pattern_title) % dict(<genexpr>(self.pattern_values['title'])), confirm_action=_update)
kbd.show()
]:
	i: 9(), 17()
	o: 

nname: 17
n 17(None)[]:
	i: 0(t)
	o: 18()

nname: 9
n 9(None)[]:
	i: 0(f)
	o: 18()

nname: 0
n 0(self._can_modify)[]:
	i: 
	o: 9(f), 17(t)

nname: 0
n 0(None)[if not self._can_modify:
	pass
def _update():
	val = kbd.text
	self.update_addr(val)
	kbd.hide()
	if self._callback is not None:
		self._callback(val, *self._callback_args)
	return None

kbd = IpWindow(self.addr, title=_(self.pattern_title) % dict(<genexpr>(self.pattern_values['title'])), confirm_action=_update)
kbd.show()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75a4eec>}
nname: 6
n 6(None)[__doc__ = "\n    Mother class for classes that display network information (such as IP address, netmask...)\n    and permit to change it, if can_modify is True. In this case, an IpWindow is displayed to\n    get new addresses and a callback method can be called (if provided).\n    Informations are retrieved from MetworkManager object.\n    Custom attributes :\n     - item's name follows pattern_name. Interpolates with self.<pattern_values['name']> attribute(s)\n     - window's title (for modification) follows pattern_title.\n           Interpolates with self.<pattern_values['title']> attribute(s)\n    "
pattern_name = '%(addr)s'
pattern_title = 'IP address'
pattern_values = {'name': ('addr',), 'title': ()}
def __init__(self, can_modify, callback=None, callback_args=(), active_values=None, **kw):
	self._can_modify = can_modify
	self._callback = callback
	self._callback_args = callback_args
	if can_modify:
		pass
	_default = _('Disconnected')
	if not active_values:
		active_cfg = wn_cfg.getActiveConfigurationInfos()
		active_values = wn_dev.getDeviceInfos(active_cfg['interface'])
	if not active_values[self.attribute]:
		pass
	self.addr = active_values[self.attribute]
	ActionItem.__init__(self, name=_(self.pattern_name) % dict(<genexpr>(self.pattern_values['name'])), action=self._modify, type_='setupitem', **kw)

def update_addr(self, addr):
	if addr not in ('', self.addr):
		self.addr = addr
		self.name = _(self.pattern_name) % dict(<genexpr>(self.pattern_values['name']))
		self.reset_view()

def _modify(self):
	if not self._can_modify:
		pass
	def _update():
		val = kbd.text
		self.update_addr(val)
		kbd.hide()
		if self._callback is not None:
			self._callback(val, *self._callback_args)
		return None

	kbd = IpWindow(self.addr, title=_(self.pattern_title) % dict(<genexpr>(self.pattern_values['title'])), confirm_action=_update)
	kbd.show()

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb75a2ecc>}
nname: 6
n 6(None)[pattern_name = 'IP : %(addr)s'
pattern_title = 'IP address'
attribute = 'ipAddress'
]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb75a29ac>}
nname: 6
n 6(None)[pattern_name = 'Mask : %(addr)s'
pattern_title = 'Mask'
attribute = 'netmask'
]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb75a2c4c>}
nname: 6
n 6(None)[pattern_name = 'Gateway : %(addr)s'
pattern_title = 'Gateway'
attribute = 'gateway'
]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb75a25ec>}
nname: 0
n 0(None)[self.dns_num = dns_num
self.attribute = 'dns%s' % dns_num
NetworkParamSetupItem.__init__(self, can_modify, callback=callback, callback_args=callback_args, active_values=active_values, **kw)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75a4d4c>}
nname: 6
n 6(None)[pattern_name = 'DNS %(dns_num)s : %(addr)s'
pattern_title = 'DNS %(dns_num)s'
pattern_values = {'name': ('addr', 'dns_num'), 'title': ('dns_num',)}
def __init__(self, dns_num, can_modify, callback=None, callback_args=(), active_values=None, **kw):
	self.dns_num = dns_num
	self.attribute = 'dns%s' % dns_num
	NetworkParamSetupItem.__init__(self, can_modify, callback=callback, callback_args=callback_args, active_values=active_values, **kw)

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb75a286c>}
nname: 0
n 0(None)[from __future__ import absolute_import
from ...core import ActionItem, Item
from ...containers import GenericContainer
from pygui.menu.menu import Menu
from peewee.messages import send as louie_send
from pygui.window import IpWindow
from wynetwork import wynetwork as wn
from pygui.config import user_config
wn_dev = wn.NetDevices()
wn_cfg = wn.NetConfigurations()
class ConnectionTypeContainer(GenericContainer):
	def __init__(self, callback, **kw):
		GenericContainer.__init__(self, **kw)
		self._callback = callback

	def browse(self):
		return [ActionItem(name=_('Ethernet'), type_='setupparameters', action=self._callback, args=('802.3',)), ActionItem(name=_('Wireless'), type_='setupparameters', action=self._callback, args=('802.11',))]



class AutoManConnectionContainer(GenericContainer):
	def __init__(self, callback, **kw):
		GenericContainer.__init__(self, **kw)
		self._callback = callback

	def browse(self):
		return [ActionItem(name=_('Automatic'), type_='setupparameters', action=self._callback, args=('upnp',)), ActionItem(name=_('Manual'), type_='setupparameters', action=self._callback, args=('static',))]



class AuthTypeConnectionContainer(GenericContainer):
	def __init__(self, callback, **kw):
		GenericContainer.__init__(self, **kw)
		self._callback = callback

	def browse(self):
		from pygui.facilities.codemapping import wifi_security_dict
		it_list = []
		for key_type, infos in wifi_security_dict.items():
			caption = infos['caption']
			it_list.append(ActionItem(caption, type_='setupitem', action=self._callback, args=(infos,)))
		return it_list



class NetworkWireSetupItem(ActionItem):
	def browse(self):
		pass

	def __init__(self, *args, **args):
		ActionItem.__init__(self, action=self.launch_config, type_='setupparameters', **kw)

	def launch_config(self):
		from pygui.menu.menu.network_connect import NetworkConnectMenu
		NetworkConnectMenu(name='ConnectionMenu', type='network_connect').show()



class EditNetworkConfSetupItem(GenericContainer):
	__doc__ = ' Used for manual network setting '
	def __init__(self, callback, default_values, **kw):
		GenericContainer.__init__(self, **kw)
		self._callback = callback
		self._default_values = default_values

	def _update_values(self, value, key):
		self._default_values[key] = value

	def browse(self):
		return [IpSetupItem(can_modify=True, callback=self._update_values, callback_args=('ipAddress',), active_values=self._default_values), NetmaskSetupItem(can_modify=True, callback=self._update_values, callback_args=('netmask',), active_values=self._default_values), GatewaySetupItem(can_modify=True, callback=self._update_values, callback_args=('gateway',), active_values=self._default_values), DnsSetupItem(dns_num=1, can_modify=True, callback=self._update_values, callback_args=('dns1',), active_values=self._default_values), DnsSetupItem(dns_num=2, can_modify=True, callback=self._update_values, callback_args=('dns2',), active_values=self._default_values), ActionItem(_('Apply'), type_='setupitem', action=self._callback, args=[self._default_values])]



class StatusNetworkConfSetupItem(GenericContainer):
	depth = 2
	def __init__(self, can_modify, **kw):
		GenericContainer.__init__(self, **kw)
		self._can_modify = can_modify

	def browse(self):
		trans = {'802.3': _('Ethernet'), '802.11': _('Wireless'), None: _('Disconnected')}
		active_cfg = wn_cfg.getActiveConfigurationInfos()
		dev_infos = wn_dev.getDeviceInfos(active_cfg['interface'])
		return [Item(trans[dev_infos['networkType']], type_='setupitem'), IpSetupItem(can_modify=self._can_modify, active_values=dev_infos), NetmaskSetupItem(can_modify=self._can_modify, active_values=dev_infos), GatewaySetupItem(can_modify=self._can_modify, active_values=dev_infos), DnsSetupItem(dns_num=1, can_modify=self._can_modify, active_values=dev_infos), DnsSetupItem(dns_num=2, can_modify=self._can_modify, active_values=dev_infos), Item(_('MAC : %(addr)s') % dict(addr=dev_infos['hwAddress']), type_='setupitem')]



class NetworkParamSetupItem(ActionItem):
	__doc__ = "\n    Mother class for classes that display network information (such as IP address, netmask...)\n    and permit to change it, if can_modify is True. In this case, an IpWindow is displayed to\n    get new addresses and a callback method can be called (if provided).\n    Informations are retrieved from MetworkManager object.\n    Custom attributes :\n     - item's name follows pattern_name. Interpolates with self.<pattern_values['name']> attribute(s)\n     - window's title (for modification) follows pattern_title.\n           Interpolates with self.<pattern_values['title']> attribute(s)\n    "
	pattern_name = '%(addr)s'
	pattern_title = 'IP address'
	pattern_values = {'name': ('addr',), 'title': ()}
	def __init__(self, can_modify, callback=None, callback_args=(), active_values=None, **kw):
		self._can_modify = can_modify
		self._callback = callback
		self._callback_args = callback_args
		if can_modify:
			pass
		_default = _('Disconnected')
		if not active_values:
			active_cfg = wn_cfg.getActiveConfigurationInfos()
			active_values = wn_dev.getDeviceInfos(active_cfg['interface'])
		if not active_values[self.attribute]:
			pass
		self.addr = active_values[self.attribute]
		ActionItem.__init__(self, name=_(self.pattern_name) % dict(<genexpr>(self.pattern_values['name'])), action=self._modify, type_='setupitem', **kw)

	def update_addr(self, addr):
		if addr not in ('', self.addr):
			self.addr = addr
			self.name = _(self.pattern_name) % dict(<genexpr>(self.pattern_values['name']))
			self.reset_view()

	def _modify(self):
		if not self._can_modify:
			pass
		def _update():
			val = kbd.text
			self.update_addr(val)
			kbd.hide()
			if self._callback is not None:
				self._callback(val, *self._callback_args)
			return None

		kbd = IpWindow(self.addr, title=_(self.pattern_title) % dict(<genexpr>(self.pattern_values['title'])), confirm_action=_update)
		kbd.show()



class IpSetupItem(NetworkParamSetupItem):
	pattern_name = 'IP : %(addr)s'
	pattern_title = 'IP address'
	attribute = 'ipAddress'


class NetmaskSetupItem(NetworkParamSetupItem):
	pattern_name = 'Mask : %(addr)s'
	pattern_title = 'Mask'
	attribute = 'netmask'


class GatewaySetupItem(NetworkParamSetupItem):
	pattern_name = 'Gateway : %(addr)s'
	pattern_title = 'Gateway'
	attribute = 'gateway'


class DnsSetupItem(NetworkParamSetupItem):
	pattern_name = 'DNS %(dns_num)s : %(addr)s'
	pattern_title = 'DNS %(dns_num)s'
	pattern_values = {'name': ('addr', 'dns_num'), 'title': ('dns_num',)}
	def __init__(self, dns_num, can_modify, callback=None, callback_args=(), active_values=None, **kw):
		self.dns_num = dns_num
		self.attribute = 'dns%s' % dns_num
		NetworkParamSetupItem.__init__(self, can_modify, callback=callback, callback_args=callback_args, active_values=active_values, **kw)



]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb758ffec>}
from __future__ import absolute_import
from ...core import ActionItem, Item
from ...containers import GenericContainer
from pygui.menu.menu import Menu
from peewee.messages import send as louie_send
from pygui.window import IpWindow
from wynetwork import wynetwork as wn
from pygui.config import user_config
wn_dev = wn.NetDevices()
wn_cfg = wn.NetConfigurations()
class ConnectionTypeContainer(GenericContainer):
	def __init__(self, callback, **kw):
		GenericContainer.__init__(self, **kw)
		self._callback = callback

	def browse(self):
		return [ActionItem(name=_('Ethernet'), type_='setupparameters', action=self._callback, args=('802.3',)), ActionItem(name=_('Wireless'), type_='setupparameters', action=self._callback, args=('802.11',))]



class AutoManConnectionContainer(GenericContainer):
	def __init__(self, callback, **kw):
		GenericContainer.__init__(self, **kw)
		self._callback = callback

	def browse(self):
		return [ActionItem(name=_('Automatic'), type_='setupparameters', action=self._callback, args=('upnp',)), ActionItem(name=_('Manual'), type_='setupparameters', action=self._callback, args=('static',))]



class AuthTypeConnectionContainer(GenericContainer):
	def __init__(self, callback, **kw):
		GenericContainer.__init__(self, **kw)
		self._callback = callback

	def browse(self):
		from pygui.facilities.codemapping import wifi_security_dict
		it_list = []
		for key_type, infos in wifi_security_dict.items():
			caption = infos['caption']
			it_list.append(ActionItem(caption, type_='setupitem', action=self._callback, args=(infos,)))
		return it_list



class NetworkWireSetupItem(ActionItem):
	def browse(self):
		pass

	def __init__(self, *args, **args):
		ActionItem.__init__(self, action=self.launch_config, type_='setupparameters', **kw)

	def launch_config(self):
		from pygui.menu.menu.network_connect import NetworkConnectMenu
		NetworkConnectMenu(name='ConnectionMenu', type='network_connect').show()



class EditNetworkConfSetupItem(GenericContainer):
	__doc__ = ' Used for manual network setting '
	def __init__(self, callback, default_values, **kw):
		GenericContainer.__init__(self, **kw)
		self._callback = callback
		self._default_values = default_values

	def _update_values(self, value, key):
		self._default_values[key] = value

	def browse(self):
		return [IpSetupItem(can_modify=True, callback=self._update_values, callback_args=('ipAddress',), active_values=self._default_values), NetmaskSetupItem(can_modify=True, callback=self._update_values, callback_args=('netmask',), active_values=self._default_values), GatewaySetupItem(can_modify=True, callback=self._update_values, callback_args=('gateway',), active_values=self._default_values), DnsSetupItem(dns_num=1, can_modify=True, callback=self._update_values, callback_args=('dns1',), active_values=self._default_values), DnsSetupItem(dns_num=2, can_modify=True, callback=self._update_values, callback_args=('dns2',), active_values=self._default_values), ActionItem(_('Apply'), type_='setupitem', action=self._callback, args=[self._default_values])]



class StatusNetworkConfSetupItem(GenericContainer):
	depth = 2
	def __init__(self, can_modify, **kw):
		GenericContainer.__init__(self, **kw)
		self._can_modify = can_modify

	def browse(self):
		trans = {'802.3': _('Ethernet'), '802.11': _('Wireless'), None: _('Disconnected')}
		active_cfg = wn_cfg.getActiveConfigurationInfos()
		dev_infos = wn_dev.getDeviceInfos(active_cfg['interface'])
		return [Item(trans[dev_infos['networkType']], type_='setupitem'), IpSetupItem(can_modify=self._can_modify, active_values=dev_infos), NetmaskSetupItem(can_modify=self._can_modify, active_values=dev_infos), GatewaySetupItem(can_modify=self._can_modify, active_values=dev_infos), DnsSetupItem(dns_num=1, can_modify=self._can_modify, active_values=dev_infos), DnsSetupItem(dns_num=2, can_modify=self._can_modify, active_values=dev_infos), Item(_('MAC : %(addr)s') % dict(addr=dev_infos['hwAddress']), type_='setupitem')]



class NetworkParamSetupItem(ActionItem):
	__doc__ = "\n    Mother class for classes that display network information (such as IP address, netmask...)\n    and permit to change it, if can_modify is True. In this case, an IpWindow is displayed to\n    get new addresses and a callback method can be called (if provided).\n    Informations are retrieved from MetworkManager object.\n    Custom attributes :\n     - item's name follows pattern_name. Interpolates with self.<pattern_values['name']> attribute(s)\n     - window's title (for modification) follows pattern_title.\n           Interpolates with self.<pattern_values['title']> attribute(s)\n    "
	pattern_name = '%(addr)s'
	pattern_title = 'IP address'
	pattern_values = {'name': ('addr',), 'title': ()}
	def __init__(self, can_modify, callback=None, callback_args=(), active_values=None, **kw):
		self._can_modify = can_modify
		self._callback = callback
		self._callback_args = callback_args
		if can_modify:
			pass
		_default = _('Disconnected')
		if not active_values:
			active_cfg = wn_cfg.getActiveConfigurationInfos()
			active_values = wn_dev.getDeviceInfos(active_cfg['interface'])
		if not active_values[self.attribute]:
			pass
		self.addr = active_values[self.attribute]
		ActionItem.__init__(self, name=_(self.pattern_name) % dict(<genexpr>(self.pattern_values['name'])), action=self._modify, type_='setupitem', **kw)

	def update_addr(self, addr):
		if addr not in ('', self.addr):
			self.addr = addr
			self.name = _(self.pattern_name) % dict(<genexpr>(self.pattern_values['name']))
			self.reset_view()

	def _modify(self):
		if not self._can_modify:
			pass
		def _update():
			val = kbd.text
			self.update_addr(val)
			kbd.hide()
			if self._callback is not None:
				self._callback(val, *self._callback_args)
			return None

		kbd = IpWindow(self.addr, title=_(self.pattern_title) % dict(<genexpr>(self.pattern_values['title'])), confirm_action=_update)
		kbd.show()



class IpSetupItem(NetworkParamSetupItem):
	pattern_name = 'IP : %(addr)s'
	pattern_title = 'IP address'
	attribute = 'ipAddress'


class NetmaskSetupItem(NetworkParamSetupItem):
	pattern_name = 'Mask : %(addr)s'
	pattern_title = 'Mask'
	attribute = 'netmask'


class GatewaySetupItem(NetworkParamSetupItem):
	pattern_name = 'Gateway : %(addr)s'
	pattern_title = 'Gateway'
	attribute = 'gateway'


class DnsSetupItem(NetworkParamSetupItem):
	pattern_name = 'DNS %(dns_num)s : %(addr)s'
	pattern_title = 'DNS %(dns_num)s'
	pattern_values = {'name': ('addr', 'dns_num'), 'title': ('dns_num',)}
	def __init__(self, dns_num, can_modify, callback=None, callback_args=(), active_values=None, **kw):
		self.dns_num = dns_num
		self.attribute = 'dns%s' % dns_num
		NetworkParamSetupItem.__init__(self, can_modify, callback=callback, callback_args=callback_args, active_values=active_values, **kw)



